package org.internna.ossmoney.model;

import org.springframework.roo.addon.jpa.activerecord.RooJpaActiveRecord;

@RooJpaActiveRecord(mappedSuperclass = true)
public abstract class AbstractEntity {

	@Override public boolean equals(Object other) {
		if (other instanceof AbstractEntity) {
			AbstractEntity otherEntity = (AbstractEntity) other;
			if (getClass().equals(otherEntity.getClass())) {
				return getId() != null ? getId().equals(otherEntity.getId()) : otherEntity.getId() == null;
			}
		}
		return false;
	}

	@Override public int hashCode() {
		return 120 + super.hashCode() + getClass().hashCode() + (getId() != null ? getId().hashCode() : 987);
	}

}
